//commonFriends.js
//获取应用实例
const app = getApp()
var util = require('../../../../utils/util.js')
var _this
Page({
  data: {
    value: '',
    userInfoList: [],
    msg: ''
  },
  //事件处理函数
  onLoad: function (options) {
    _this = this
    _this.setData({
      value: options.value
    })
    util.getCommonFriends(_this.requestDidResponse, _this.requestDidFaild, options.value)
  },
  enterMather(e) {
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../personalCard/personalCard?id=' + id + '&common=false',
      success (res) {
        console.log('跳转成功：' + res)
      },
      fail(res) {
        console.log('跳转失败：' + res)
      }
    })
  },
  requestDidResponse: (res) => {
    console.log(res)
    let data = res.data.result
    if (res.status == '200' && data.length > 0) {
      _this.setData({
        userInfoList: res.data.result
      })
    } else {
      _this.setData({
        msg: res.data.Msg
      })
    }
  },
  requestDidFaild: (res) => {

  },
  copyBtn (e) {
    let value = e.currentTarget.dataset.value
    wx.setClipboardData({
      data: value,
      success(res) {
        wx.getClipboardData({
          success(res) {
            wx.showToast({
              title: '复制成功，快去添加好友吧',
              icon: 'success'
            })
          }
        })
      }
    })
  }
})
